package com.zjitc.redis;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;


/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/4/26 16:13
 * @description:
 */
@Component
public class Redis implements RedisCommand{

  @Autowired
  private JedisPool pool;
  @Autowired
  public Redis(JedisPool pool){
    this.pool=pool;
  }
  @Override
  public void set(String key,String value){
    Jedis jedis=null;
    try {
      jedis=pool.getResource();
      jedis.set(key,value);
    }finally {
      if(jedis!=null){
        jedis.close();
      }
    }

  }
}
